/* Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This file is a part of the CANN Open Software.
 * Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 * ===================================================================================================================*/

#include <gtest/gtest.h>
#define private public
#define protected public
#include "base/registry/opp_package_utils.h"
#undef private
#undef protected
namespace gert {
class UtestOppPackageUtils : public testing::Test {
 protected:
  void SetUp() {}

  void TearDown() {}
};

TEST_F(UtestOppPackageUtils, OppSoDescTestSuccess) {
  OppSoDesc so_desc("/path/opp.so", "opp_desc");
  EXPECT_EQ(so_desc.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc.GetPackageName(), "opp_desc");

  auto so_desc2 = so_desc;
  EXPECT_EQ(so_desc2.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc2.GetPackageName(), "opp_desc");

  OppSoDesc so_desc3(std::move(so_desc2));
  EXPECT_EQ(so_desc3.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc3.GetPackageName(), "opp_desc");

  so_desc3 = std::move(so_desc);
  EXPECT_EQ(so_desc3.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc3.GetPackageName(), "opp_desc");

  // 代码覆盖
  so_desc = so_desc;
  so_desc = std::move(so_desc);

  OppSoDesc so_desc4(so_desc3);
  EXPECT_EQ(so_desc4.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc4.GetPackageName(), "opp_desc");

  so_desc = so_desc4;
  EXPECT_EQ(so_desc.GetSoPath(), "/path/opp.so");
  EXPECT_EQ(so_desc.GetPackageName(), "opp_desc");
}

}  // namespace gert
